package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.TDiseaseLibraryMapper;
import com.hu.zhcc.shiro.entity.dingming.TDiseaseLibrary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TDiseaseLibraryServiceImpl implements TDiseaseLibraryService{
    @Autowired
    private TDiseaseLibraryMapper tDiseaseLibraryMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tDiseaseLibraryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TDiseaseLibrary record) {
        return tDiseaseLibraryMapper.insert(record);
    }

    @Override
    public int insertSelective(TDiseaseLibrary record) {
        return tDiseaseLibraryMapper.insertSelective(record);
    }

    @Override
    public TDiseaseLibrary selectByPrimaryKey(Integer id) {
        return tDiseaseLibraryMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TDiseaseLibrary record) {
        return tDiseaseLibraryMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TDiseaseLibrary record) {
        return tDiseaseLibraryMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<TDiseaseLibrary> listTHealthPlan (Map<String, Object> parameters, int offset, int limit) {
        int total = tDiseaseLibraryMapper.countHealthPlan(parameters);
        List<TDiseaseLibrary> tHealthPlans= null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            tHealthPlans = tDiseaseLibraryMapper.listHealthPlan(pageRequest);
        }
        return new Page<TDiseaseLibrary>(total, tHealthPlans);
    }
}
